<template>
  <div class='manage-home'>
    <p class="title">{{title}}</p>
    <div class="table-box">
      <Table :modelData="modelData" :listData="listData" :pageInfo="pageInfo"></Table>
    </div>
  </div>
</template>
<script>
import Table from '../../components/table'
export default {
  components: {Table},
  name: "",
  data() {
    return {
      title:"主页管理",
      modelData:[
        {myType:'index',label:"序号"},
        {myType:'normal',prop:"name",label:'栏目名称',},
        {myType:'normal',prop:"ename",label:'英文名',},
        {myType:'img',   prop:"picture",label:'栏目图片',},
        {myType:'normal',prop:"state_no",label:'状态'},
        {myType:'operate',label:'操作',btns:[
          {label:'编辑',click:this.edit,icon:require('../../assets/images/manageHome/edit.png')}
        ],width:"100"}
      ],
      listData:[
        // {
        //   id:1,
        //   name:'哈哈哈哈哈',
        //   state_no:'不显示',
        //   status:0,
        //   picture:"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2909356879,2222891748&fm=27&gp=0.jpg"
        // },
      ],
      pageInfo:{
        page:1,
        total:10,
        size:10,
        changePage:this.changePage
      },
      height:"",
    };
  },
  methods: {
    // 翻页
    changePage(){

    },

    edit(scope){
      this.$store.state.add.show = true;
      this.$store.state.add.info=JSON.parse(JSON.stringify(scope.row))
      this.$store.state.add.OK=this.saveEdit
      // console.log(this.$store.state.add.info)
    },

    saveEdit(){
      var params=this.$store.state.add.info
      params.status=params.switch?0:1
      delete params.state_no
      delete params.switch
      if(_g.checkParams(this.modelData,this.$store.state.add.info))return

      _g.apiPost("homePage/update.do",params).then(res=>{
        _g.toMessage(res)
        if(!res.error){
          this.getListData()
        }
      })
    },

    getListData(){
      var params={
        currPageNo:this.pageInfo.page
      }
      _g.apiPost('homePage/getColunmList.do',params).then(res=>{
        this.pageInfo.total=res.data.total
        res.data.list.forEach(ele => {
          ele.state_no=ele.status==0?'显示':'隐藏',
          ele.switch=ele.status==0
        });
        this.$set(this,'listData',res.data.list)
      })
    }
  },
  created() {
    this.getListData()
  },
  mounted(){
    
  }
};
</script>
<style lang="scss" scoped>
.manage-home {
  width: 100%;
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
  overflow: auto;
  
  .title{
    font-weight: 600;
    font-size: 20px;
    background-color: #fff;
    text-indent: 20px;
    height: 60px;
    line-height: 60px;
    box-sizing: border-box;
    border-bottom: 1px solid #ebeef5;
    
  }
  .table-box{
    height: calc(100% - 60px);
    // background-color: red;
  }
}
</style>